package com.tf8.treasure.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;


public class UuidTools {
	/**
	 * 获取UUID
	 * 
	 * @Title: getUuid
	 * @Description: TODO
	 * @Param @return
	 * @Return String
	 * @Throws
	 */
	public static String getUuid() {
		String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
		return uuid;

	}

	/**
	 * 产生一个随机长度的数
	 */
	public static String randomLengthNum(int lenght) {
		StringBuffer s = new StringBuffer();
		for (int i = 0; i < lenght; i++) {
			int a = (int) (Math.random() * 10);
			s.append(String.valueOf(a));
		}
		return s.toString();
	}
	
	
	/**
	 * 产生一个随机流水号
	 */

	public static String randomOrder() {
		//图片名称生成策略
		DateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS");
		//图片名称一部分时间
		String format = df.format(new Date());

		return format+=randomLengthNum(15);
			
	}
	
	public static void main(String[] args) {
		System.err.println(randomOrder());
		System.err.println(randomOrder().length());
	}

}
